<template>
  <div class="container">
    <el-dialog title="题目审核" :visible.sync="showCheck" width="400px" :before-close="handleClose">
      <el-form size="small">
        <el-form-item>
          <el-radio :label="1" v-model="checkData.chkState">通过</el-radio>
          <el-radio :label="2" v-model="checkData.chkState">拒绝</el-radio>
        </el-form-item>
        <el-form-item>
          <el-input
            type="textarea"
            v-model="checkData.chkRemarks"
            placeholder="请输入审核意见"
          ></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer">
        <el-button @click="handleClose">取消</el-button>
        <el-button @click="confirm()" type="primary">确认</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { choiceCheck } from '@/api/hmmm/questions.js'
export default {
  props: {
    showCheck: {
      type: Boolean,
      default: false
    },
    data: {
      type: Object,
      default: null
    }
  },
  data () {
    return {
      checkData: {
        id: null,
        chkState: 1,
        chkRemarks: null
      }
    }
  },
  methods: {
    handleClose () {
      this.checkData = {
        id: null,
        chkState: 1,
        chkRemarks: null
      }
      this.$emit('update:showCheck', false)
    },
    async confirm () {
      if (!this.checkData.chkRemarks) return this.$message.warning('请输入审核意见')
      this.checkData.id = this.data.id
      console.log(this.data.id)
      await choiceCheck(this.checkData)
      this.$message.success('操作成功')
      this.$emit('update:showCheck', false)
      this.$emit('updateList')
    }
  }
}
</script>

<style scoped lang="less"></style>
